/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.github.lvyanyang.core.BaseEntity;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.XCI;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 考试记录
 * @author 马星俊 maxingjun@xci96716.com
 * @since 2020-11-25 10:52:08
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "考试记录")
public class ExamRecord extends BaseEntity {
    /**
     * 考试记录主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ExcelIgnore
    @Excel(name = "考试记录主键", width = 20d)
    @ApiModelProperty(value = "考试记录主键", position = 1)
    private Long id;

    /**
     * 学员主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "学员主键不能为空")
    @Excel(name = "学员主键", width = 20d)
    @ApiModelProperty(value = "学员主键", required = true, position = 2)
    private Long studentId;

    /**
     * 学员姓名
     */
    @NotBlank(message = "学员姓名不能为空")
    @Length(max = 50, message = "学员姓名长度不能超过{max}个字符")
    @Excel(name = "学员姓名", width = 20d)
    @ApiModelProperty(value = "学员姓名", required = true, position = 3)
    private String studentName;

    /**
     * 学员证件号码
     */
    @NotBlank(message = "学员证件号码不能为空")
    @Length(max = 20, message = "学员证件号码长度不能超过{max}个字符")
    @Excel(name = "学员证件号码", width = 20d)
    @ApiModelProperty(value = "学员证件号码", required = true, position = 4)
    private String studentIdNumber;

    /**
     * 试卷主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "试卷主键不能为空")
    @Excel(name = "试卷主键", width = 20d)
    @ApiModelProperty(value = "试卷主键", required = true, position = 5)
    private Long paperId;

    /**
     * 试卷名称
     */
    @NotBlank(message = "试卷名称不能为空")
    @Length(max = 50, message = "试卷名称长度不能超过{max}个字符")
    @Excel(name = "试卷名称", width = 20d)
    @ApiModelProperty(value = "试卷名称", required = true, position = 6)
    private String paperName;

    /**
     * 科目主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "科目主键不能为空")
    @Excel(name = "科目主键", width = 20d)
    @ApiModelProperty(value = "科目主键", required = true, position = 7)
    private Long eduCategoryId;

    /**
     * 科目名称
     */
    @NotBlank(message = "科目名称不能为空")
    @Length(max = 50, message = "科目名称长度不能超过{max}个字符")
    @Excel(name = "科目名称", width = 20d)
    @ApiModelProperty(value = "科目名称", required = true, position = 8)
    private String eduCategoryName;

    /**
     * 学员考试分数
     */
    @Excel(name = "学员考试分数", width = 20d)
    @ApiModelProperty(value = "学员考试分数", required = true, position = 9)
    private Integer examScore;

    /**
     * 学员考试结果[0-不及格, 1-及格]
     */
    @Excel(name = "学员考试结果", width = 20d, replace = { "不及格_0", "及格_1" })
    @ApiModelProperty(value = "学员考试结果[0-不及格, 1-及格]", required = true, position = 10)
    private Integer examResult;
    /**
     * 学员考试结果名称
     */
    @Excel(name = "预约类型名称", width = 20d)
    @ApiModelProperty(value = "预约类型名称", position = 9)
    private String examResultName;

    /**
     * 学员考试结果名称
     */
    public String getExamResultName(){
        if(XCI.isEmpty(examResult)){
            return Const.Empty;
        }
        switch(examResult) {
            case 0:
                return "不及格";
            case 1:
                return "及格";
        }
        return Const.Empty;
    }
    /**
     * 开考时间
     */
    @Excel(name = "开考时间", width = 20d, exportFormat = Const.DEFAULT_DATETIME_PATTERN)
    @ApiModelProperty(value = "开考时间", required = true, position = 11)
    private Date examStartDateTime;

    /**
     * 交卷时间
     */
    @Excel(name = "交卷时间", width = 20d, exportFormat = Const.DEFAULT_DATETIME_PATTERN)
    @ApiModelProperty(value = "交卷时间", required = true, position = 12)
    private Date examEndDateTime;

    /**
     * 开始用时(分钟)
     */
    @Excel(name = "开始用时(分钟)", width = 20d)
    @ApiModelProperty(value = "开始用时(分钟)", required = true, position = 13)
    private Integer examDuration;

    /**
     * 状态[0-考试中, 1-已交卷]
     */
    @NotNull(message = "状态不能为空")
    @Excel(name = "状态", width = 20d, replace = { "考试中_0", "已交卷_1"})
    @ApiModelProperty(value = "状态[0-考试中, 1-已交卷]", required = true, position = 14)
    private Integer status;

    @Override
    public String toString() {
        return "ExamRecord{" +
                "id=" + id +
                ", studentId=" + studentId +
                ", studentName='" + studentName + '\'' +
                ", studentIdNumber='" + studentIdNumber + '\'' +
                ", paperId=" + paperId +
                ", paperName='" + paperName + '\'' +
                ", eduCategoryId=" + eduCategoryId +
                ", eduCategoryName='" + eduCategoryName + '\'' +
                ", examScore=" + examScore +
                ", examResult=" + examResult +
                ", examResultName='" + examResultName + '\'' +
                ", examStartDateTime=" + examStartDateTime +
                ", examEndDateTime=" + examEndDateTime +
                ", examDuration=" + examDuration +
                ", status=" + status +
                '}';
    }
}